<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>关于居中</title>
    <style>
        .box{
            width: 300px;
            height: 200px;
            border: 2px solid red;
            font-size: 32px;
            margin: auto;

            /* text-align: center; */
        }
        .box button{
            display: block;
            margin: auto;
        }
        /* 行内元素居中是在外层的块级元素上面加text-align:center */
    </style>
</head>
<body>
    <div class="box">
        <button>按钮</button>
    </div>
</body>
</html>